<template>
<div class="tabbar">
    <div  v-for="(item,index) in btnArr" :key="index" @click="colorChange(index)" :class="{active:currentIndex == index}">
        <p>{{item}}</p>
    </div>
    
</div>
</template>

<script>
//在组件内部使用this, 这个this代表当前组件的实例
export default {
    data(){
        return {
            currentIndex:0,
            btnArr:["首页","订单","我的"],
        }
    },
    methods:{
        colorChange(index){
            this.currentIndex = index;
        }
    }
}
</script>

<style lang="scss" scoped>
.tabbar{
    width: 100%;
    height: 50px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0px;
    background-color: #fff;
}
.tabbar p{
    line-height: 50px;
}
.tabbar .active{
    color: cornflowerblue;
}
</style>